/** Doctor class */

package edu.gatech.userclasses;

import edu.gatech.datastorage.DoctorsOrders;
import edu.gatech.datastorage.TreatmentRecord;
import edu.gatech.utilities.Persistence;

/**
 * Doctor class has all the same privileges as a nurse, plus the ability to
 * create Orders and view Reports.
 * 
 * @author Daniel Holdridge
 * @version 1.0
 */
public class Doctor extends Nurse {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3590169036215717996L;

	/** Constructor for Doctor with one parameter
	 * @param name */
	public Doctor(String name) {
		this.name = name;
		this.userType = "Doctor";
	}
	
	/**
	 * Constructor for registering a doctor
	 * @param username
	 * @param password
	 */
	public Doctor(String username, String password){
		this.username = username;
		this.password = password;
		this.name = username;
		this.userType = "Doctor";
	}
	
	/** Default constructor for Doctor (calls super by default) */
	public Doctor() {
		this.userType = "Doctor";
	}

	/**
	 * Creates a new set of DoctorsOrders and adds it to the patient's
	 * TreatmentRecord
	 * 
	 * @param patient
	 *            The patient who the orders are for
	 * @param doc
	 * 			The doctors order for the patient
	 * 
	 * @param followUp
	 */
	public void addOrders(Patient patient, DoctorsOrders doc, boolean followUp) {
		/*
		 * TODO Find the right TreatmentRecord object to add the orders to. Temp
		 * fix - the last TreatmentRecord in the history list
		 */
		final TreatmentRecord record;
		record = patient.getInfo().getLastRecord();
		if(record != null){
			record.setOrders(doc);
		}
		//TODO This will allow the doctor to schedule a follow-up appointment. 
		//Do you guys think this is a good idea?
		
//		if (followUp)
//		{
//		tempPatient.getInfo().getHistory().add(new TreatmentRecord("Follow-up appointment",
//				followUpDate, followUpTime, this.getName()));
//		}
		Persistence.save();
	}

	/**
	 * Edits a doctor with additional or altered information
	 * @param name
	 * @param username
	 * @param password
	 * @param address
	 * @param phoneNumber
	 */
	public void editDoctor(String name, String username, String password, String address, 
			String phoneNumber){
		this.setName (name);
		this.setusername(username);
		this.setPassword(password);
		this.setAddress(address);
		this.setPhoneNumber(phoneNumber);
	}
	
	/**
	 * Deletes this instance of a doctor
	 */
	public void deleteDoctor(){
		Persistence.getUserList().remove(this);
		Persistence.refresh();
	}
}
